// DriveNotes. Copyright (c) 2011, Andrei Senchuk. All rights reserved.
package net.taviscaron.drivenotes.server.service.endpoint;

import java.util.List;
import javax.jws.WebMethod;
import javax.jws.WebService;
import net.taviscaron.drivenotes.shared.exceptions.InvalidEntityException;
import net.taviscaron.drivenotes.shared.model.entity.Car;
import net.taviscaron.drivenotes.shared.model.entity.User;
import net.taviscaron.drivenotes.shared.service.GarageService;
import org.springframework.beans.factory.annotation.Autowired;

/**
 * Garage service impl
 * @author Andrei Senchuk
 */
@WebService(serviceName = "GarageService")
public class GarageServiceEndpoint implements GarageService {
    @Autowired
    private GarageService garageService;

    @WebMethod
    public List<Car> findCarsByOwnerId(Long ownerId) {
        return garageService.findCarsByOwnerId(ownerId);
    }

    @WebMethod
    public Car findCar(Long carId, User owner) {
        return garageService.findCar(carId, owner);
    }

    @WebMethod
    public void saveCar(Car car) throws InvalidEntityException {
        garageService.saveCar(car);
    }

    @WebMethod
    public void removeCarById(Long id) {
        garageService.removeCarById(id);
    }
}
